#pragma once

#define MAXPOW   10
#define MAXSZ    ((1<<MAXPOW)+1)

namespace Graphics{
	class LandscapeGenerator{
	public:
		LandscapeGenerator(double falloff);

		void render(RenderContext* context);
	private:
		void diamondSquare(int n, double falloff);
		void normalize();
		void drawImage();
		void generateVertexBuffer();
		void generateIndexBuffer();
		static double randf();

		double m_heightMap[MAXSZ][MAXSZ];
		unsigned char m_heightImg[MAXSZ][MAXSZ*4];

		int pow,sz,indCount;

		VertexBufferPtr m_vertBuff;
		IndexBufferPtr m_indBuff;
	};
}